/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gl;

import ctrl.WorldCtrl;

/**
 *
 * @author Administrateur
 */
public class GUI_Param extends javax.swing.JFrame {
    private WorldCtrl ctrl;
    private GUI_Game game;
    

    /**
     * Creates new form GUI_Param
     */

    GUI_Param() {
        ctrl = new WorldCtrl();
        initComponents();
        tHeight.setValue(6);
        tWidth.setValue(6);
        tSpeed.setValue(200);
        tNbrPlanque.setValue(5);
        tNbrAgents.setValue(3);
        tNbrTruand.setValue(5);
        desactivateAll();
    }
    
    private void desactivateAll(){
            tHeight.setEnabled(false);
            tWidth.setEnabled(false);
            tNbrAgents.setEnabled(false);
            tNbrPlanque.setEnabled(false);
            tNbrTruand.setEnabled(false);
            tSpeed.setEnabled(false);
            tBtStart.setEnabled(false);
            sSpeed.setEnabled(false);
            sBtStart.setEnabled(false);
        
    }
    
    private void activateTruands(){
            // On active les options pour le jeux Truands
            tHeight.setEnabled(true);
            tWidth.setEnabled(true);
            tNbrAgents.setEnabled(true);
            tNbrPlanque.setEnabled(true);
            tNbrTruand.setEnabled(true);
            tSpeed.setEnabled(true);
            tBtStart.setEnabled(true);
            // On désactive les options pour le jeux StarWars
            sSpeed.setEnabled(false);
            sBtStart.setEnabled(false);
            // On met les toggle à jour
            btPlayTruands.setEnabled(false);
            btPlayStarWars.setEnabled(true);
        
    }
    
    private void activateStarWars(){
            // On active les options pour le jeux StarWars
            sSpeed.setEnabled(true);
            sBtStart.setEnabled(true);
            // On désactive les options pour le jeux Truands
            tHeight.setEnabled(false);
            tWidth.setEnabled(false);
            tNbrAgents.setEnabled(false);
            tNbrPlanque.setEnabled(false);
            tNbrTruand.setEnabled(false);
            tSpeed.setEnabled(false);
            tBtStart.setEnabled(false);
            // On met les toggle à jour
            btPlayStarWars.setEnabled(false);
            btPlayTruands.setEnabled(true);
            
            

        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        pTruands = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        tNbrTruand = new javax.swing.JSpinner();
        tNbrAgents = new javax.swing.JSpinner();
        tNbrPlanque = new javax.swing.JSpinner();
        jLabel5 = new javax.swing.JLabel();
        tSpeed = new javax.swing.JSpinner();
        tBtStart = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        tHeight = new javax.swing.JSpinner();
        tWidth = new javax.swing.JSpinner();
        pStarWars = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        sSpeed = new javax.swing.JSpinner();
        sBtStart = new javax.swing.JButton();
        btPlayStarWars = new javax.swing.JButton();
        btPlayTruands = new javax.swing.JButton();
        btExit = new javax.swing.JButton();
        modeConsol = new javax.swing.JCheckBox();
        lbBackGround = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        pTruands.setBackground(new java.awt.Color(51, 51, 51));

        jLabel2.setForeground(new java.awt.Color(204, 204, 204));
        jLabel2.setText("Nombre de truands");

        jLabel3.setForeground(new java.awt.Color(204, 204, 204));
        jLabel3.setText("Nombre d'agents");

        jLabel4.setForeground(new java.awt.Color(204, 204, 204));
        jLabel4.setText("Nombre de planques");

        jLabel5.setForeground(new java.awt.Color(204, 204, 204));
        jLabel5.setText("Vitesse (action/s)");

        tBtStart.setText("Lancer la partie...");
        tBtStart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tBtStartActionPerformed(evt);
            }
        });

        jLabel6.setForeground(new java.awt.Color(204, 204, 204));
        jLabel6.setText("Hauteur");

        jLabel7.setForeground(new java.awt.Color(204, 204, 204));
        jLabel7.setText("Largeur");

        javax.swing.GroupLayout pTruandsLayout = new javax.swing.GroupLayout(pTruands);
        pTruands.setLayout(pTruandsLayout);
        pTruandsLayout.setHorizontalGroup(
            pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pTruandsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(tBtStart, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(pTruandsLayout.createSequentialGroup()
                            .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel6)
                                .addComponent(jLabel7))
                            .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(pTruandsLayout.createSequentialGroup()
                                    .addGap(96, 96, 96)
                                    .addComponent(tWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(pTruandsLayout.createSequentialGroup()
                                    .addGap(99, 99, 99)
                                    .addComponent(tHeight))))))
                .addContainerGap(199, Short.MAX_VALUE))
            .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(pTruandsLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel2)
                        .addComponent(jLabel3)
                        .addComponent(jLabel5))
                    .addGap(27, 27, 27)
                    .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pTruandsLayout.createSequentialGroup()
                            .addComponent(tSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap())
                        .addGroup(pTruandsLayout.createSequentialGroup()
                            .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(tNbrAgents)
                                    .addComponent(tNbrPlanque, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(tNbrTruand))
                            .addGap(205, 205, 205)))))
        );
        pTruandsLayout.setVerticalGroup(
            pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pTruandsLayout.createSequentialGroup()
                .addContainerGap(68, Short.MAX_VALUE)
                .addComponent(jLabel4)
                .addGap(55, 55, 55)
                .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(tHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(tWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(69, 69, 69)
                .addComponent(tBtStart, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(17, 17, 17))
            .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(pTruandsLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(tNbrTruand, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(9, 9, 9)
                    .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(tNbrAgents, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(tNbrPlanque, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(pTruandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel5)
                        .addComponent(tSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(191, Short.MAX_VALUE)))
        );

        pTruands.setBounds(360, 190, 220, 330);
        jLayeredPane1.add(pTruands, javax.swing.JLayeredPane.DEFAULT_LAYER);

        pStarWars.setBackground(new java.awt.Color(51, 51, 51));

        jLabel11.setForeground(new java.awt.Color(204, 204, 204));
        jLabel11.setText("Vitesse (action/s)");

        sSpeed.setValue(100);

        sBtStart.setText("Lancer la partie...");
        sBtStart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sBtStartActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pStarWarsLayout = new javax.swing.GroupLayout(pStarWars);
        pStarWars.setLayout(pStarWarsLayout);
        pStarWarsLayout.setHorizontalGroup(
            pStarWarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pStarWarsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pStarWarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(sBtStart, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pStarWarsLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(18, 18, 18)
                        .addComponent(sSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        pStarWarsLayout.setVerticalGroup(
            pStarWarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pStarWarsLayout.createSequentialGroup()
                .addContainerGap(104, Short.MAX_VALUE)
                .addGroup(pStarWarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addGap(135, 135, 135)
                .addComponent(sBtStart, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(19, 19, 19))
        );

        pStarWars.setBounds(30, 190, 220, 330);
        jLayeredPane1.add(pStarWars, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btPlayStarWars.setText("Jouer à StarWars Life");
        btPlayStarWars.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPlayStarWarsActionPerformed(evt);
            }
        });
        btPlayStarWars.setBounds(40, 150, 172, 29);
        jLayeredPane1.add(btPlayStarWars, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btPlayTruands.setText("Jouer à Truands Life");
        btPlayTruands.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPlayTruandsActionPerformed(evt);
            }
        });
        btPlayTruands.setBounds(380, 150, 169, 29);
        jLayeredPane1.add(btPlayTruands, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btExit.setText("Quitter");
        btExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btExitActionPerformed(evt);
            }
        });
        btExit.setBounds(240, 530, 130, 30);
        jLayeredPane1.add(btExit, javax.swing.JLayeredPane.DEFAULT_LAYER);

        modeConsol.setBackground(new java.awt.Color(0, 0, 0));
        modeConsol.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        modeConsol.setForeground(new java.awt.Color(255, 255, 255));
        modeConsol.setLabel("Mode console");
        modeConsol.setBounds(30, 530, 120, 25);
        jLayeredPane1.add(modeConsol, javax.swing.JLayeredPane.DEFAULT_LAYER);
        modeConsol.getAccessibleContext().setAccessibleName("mode");

        lbBackGround.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/bgParam.jpg"))); // NOI18N
        lbBackGround.setBounds(0, -20, 600, 620);
        jLayeredPane1.add(lbBackGround, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 80, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 40, Short.MAX_VALUE)
        );

        jPanel1.setBounds(20, 540, 80, 40);
        jLayeredPane1.add(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 590, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tBtStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tBtStartActionPerformed
                if(modeConsol.isSelected()){
            game = new GUI_TruandGame(ctrl,"consol");
        }else{
            game = new GUI_TruandGame(ctrl,"map");
        }
        
        ctrl.setGame(game);
        ctrl.sendParametres((int)tNbrAgents.getValue(), (int)tNbrTruand.getValue(),(int)tHeight.getValue(),(int)tWidth.getValue(), (int)tNbrPlanque.getValue(), (int)tSpeed.getValue());
        game.setSideImage(1);
        game.setVisible(true);
    }//GEN-LAST:event_tBtStartActionPerformed

    private void btPlayStarWarsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPlayStarWarsActionPerformed
        
        activateStarWars();
    }//GEN-LAST:event_btPlayStarWarsActionPerformed

    private void btPlayTruandsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPlayTruandsActionPerformed
        activateTruands();
    }//GEN-LAST:event_btPlayTruandsActionPerformed

    private void sBtStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sBtStartActionPerformed
        if(modeConsol.isSelected()){
            game = new GUI_StarwarsGame(ctrl,"consol");
        }else{
            game = new GUI_StarwarsGame(ctrl,"map");
        }
        
        ctrl.setGame(game);
        ctrl.sendParametres(5, 5, 5, (int)sSpeed.getValue());
        game.setSideImage(0);
        game.setVisible(true);
    }//GEN-LAST:event_sBtStartActionPerformed

    private void btExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExitActionPerformed
        System.exit(0);
    }//GEN-LAST:event_btExitActionPerformed

    private void modeConsolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modeConsolActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_modeConsolActionPerformed

    /**
     * @param args the command line arguments
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btExit;
    private javax.swing.JButton btPlayStarWars;
    private javax.swing.JButton btPlayTruands;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lbBackGround;
    private javax.swing.JCheckBox modeConsol;
    private javax.swing.JPanel pStarWars;
    private javax.swing.JPanel pTruands;
    private javax.swing.JButton sBtStart;
    private javax.swing.JSpinner sSpeed;
    private javax.swing.JButton tBtStart;
    private javax.swing.JSpinner tHeight;
    private javax.swing.JSpinner tNbrAgents;
    private javax.swing.JSpinner tNbrPlanque;
    private javax.swing.JSpinner tNbrTruand;
    private javax.swing.JSpinner tSpeed;
    private javax.swing.JSpinner tWidth;
    // End of variables declaration//GEN-END:variables
}
